package com.dynastqin.service;

import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

/**
 * spring bean注入静态变量，实现静态方法调用第三方bean的方法(同时达到了隐藏第三方bean的作用)
 * Created by tantao on 14-9-23.
 */
public class ServiceUtils {
    private final static Logger log = LoggerFactory.getLogger(ServiceUtils.class);
    private static ServiceUtils serviceUtils;

    public static String PROJECT_NAME;

    public static int substract(int a,int b){
        log.error("调用com.dynastqin.service.MyService#substract（测试日志error级别）");
        return serviceUtils.myService.substract(a,b);
    }

    public void init(){
        PROJECT_NAME=this.projectName;

        serviceUtils=this;
        serviceUtils.myService=this.myService;
    }

    private String projectName;
    private MyService myService;

    public void setProjectName(String projectName) {
        this.projectName = projectName;
    }

    public void setMyService(MyService myService) {
        this.myService = myService;
    }
}